package net.cyndeline.scalarlib.rldungeon.dgs.strategy.pointlessArea.algorithms.help

import net.cyndeline.scalarlib.rldungeon.dgs.graph.Room
import net.cyndeline.scalarlib.rldungeon.dgs.strategy.help.CollapsedNode

/**
 * Contains room and collapsed node data for a single pointless area.
 *
 * @constructor Create a container for a set of pointless-area data.
 * @param pointlessRooms Rooms belonging to a single pointless area.
 * @param mainPathConnection The room connecting the area to the main path of the level.
 * @param roomNodes The collapsed nodes representing the pointless area rooms in a cycle-collapsed graph.
 * @param mainPathConnectionNode The collapsed node representing the main path room.
 * @tparam VType Object type of representing the rooms.
 */
case class PointlessAreaResult[VType <: Room[VType]](pointlessRooms: Set[VType],
                                                     mainPathConnection: VType,
                                                     roomNodes: Set[CollapsedNode[VType]],
                                                     mainPathConnectionNode: CollapsedNode[VType]) {

  override def equals(other: Any): Boolean = other match {
    case r: PointlessAreaResult[VType] => r.pointlessRooms == pointlessRooms &&
      r.mainPathConnection == mainPathConnection &&
      r.roomNodes == roomNodes &&
      r.mainPathConnectionNode == mainPathConnectionNode
    case _ => false
  }

  override def hashCode: Int = pointlessRooms.## ^ mainPathConnection.## ^ roomNodes.## ^ mainPathConnectionNode.## << 32
}
